<?php
	session_start();
	if(!isset($_SESSION['nom']) AND !isset($_POST['nom']))
	{
		header('Location: logger.php');
	}
	else if (!isset($_SESSION['nom'])) 
	{
	
		$bdd = new PDO('mysql:host=localhost;dbname=utilisateur', 'root', '');
		echo $_POST['nom'];
		$reponse = $bdd->query('SELECT mdp FROM utilisateur WHERE login=\'' . $_POST['nom'] . '\'');
		
		$donnees=$reponse->fetch();
		
		$mdp=$donnees['mdp'];
		
		if($reponse->rowCount()!=0 AND $mdp==$_POST['mdp'])
		{
			
			$_SESSION['nom']=$_POST['nom'];
		}
		else
		{
			header('Location: logger.php');
		}
	}
		echo "vous etes sur la page<br/>";
		echo "bienvenue ".$_SESSION['nom']."<br/>";
		?>
		<a href="profil.php">Lien vers autre.php</a>
		<?php
	
	
	
?>